
<html>
<title>transform - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href=cdrom.html>Cdrom</a>&nbsp;||&nbsp;
<a href=cursors.html>Cursors</a>&nbsp;||&nbsp;
<a href=display.html>Display</a>&nbsp;||&nbsp;
<a href=draw.html>Draw</a>&nbsp;||&nbsp;
<a href=event.html>Event</a>&nbsp;||&nbsp;
<a href=font.html>Font</a>&nbsp;||&nbsp;
<a href=image.html>Image</a>&nbsp;||&nbsp;
<a href=joystick.html>Joystick</a>&nbsp;||&nbsp;
<a href=key.html>Key</a>&nbsp;||&nbsp;
<a href=mixer.html>Mixer</a>&nbsp;||&nbsp;
<a href=mouse.html>Mouse</a>&nbsp;||&nbsp;
<a href=movie.html>Movie</a>&nbsp;||&nbsp;
<a href=music.html>Music</a>&nbsp;||&nbsp;
<a href=overlay.html>Overlay</a>&nbsp;||&nbsp;
<a href=pygame.html>Pygame</a>&nbsp;||&nbsp;
<a href=rect.html>Rect</a>&nbsp;||&nbsp;
<a href=scrap.html>Scrap</a>&nbsp;||&nbsp;
<a href=sndarray.html>Sndarray</a>&nbsp;||&nbsp;
<a href=sprite.html>Sprite</a>&nbsp;||&nbsp;
<a href=surface.html>Surface</a>&nbsp;||&nbsp;
<a href=surfarray.html>Surfarray</a>&nbsp;||&nbsp;
<a href=time.html>Time</a>&nbsp;||&nbsp;
<a href=transform.html>Transform</a>
</td></tr></table>
<br>


<a name="pygame.transform">
<big><b>pygame.transform</big></b><br><ul>
  <i>pygame module to transform surfaces</i><br>
<ul><small><table>
  <tr><td><a href="transform.html#pygame.transform.flip">pygame.transform.flip</a> - <font size=-1>flip vertically and horizontally</font></td><td>flip vertically and horizontally</td></tr>
  <tr><td><a href="transform.html#pygame.transform.scale">pygame.transform.scale</a> - <font size=-1>resize to new resolution</font></td><td>resize to new resolution</td></tr>
  <tr><td><a href="transform.html#pygame.transform.rotate">pygame.transform.rotate</a> - <font size=-1>rotate an image</font></td><td>rotate an image</td></tr>
  <tr><td><a href="transform.html#pygame.transform.rotozoom">pygame.transform.rotozoom</a> - <font size=-1>filtered scale and rotation</font></td><td>filtered scale and rotation</td></tr>
  <tr><td><a href="transform.html#pygame.transform.scale2x">pygame.transform.scale2x</a> - <font size=-1>specialized image doubler</font></td><td>specialized image doubler</td></tr>
  <tr><td><a href="transform.html#pygame.transform.chop">pygame.transform.chop</a> - <font size=-1>remove interior area of an image</font></td><td>remove interior area of an image</td></tr>
</table></small></ul>
<p><tt>A</tt> Surface transform is an operation that moves or resizes the pixels. All these functions take a Surface to operate on and return a new Surface with the results. </p>
<p>Some of the transforms are considered destructive. These means every time they are performed they lose pixel data. Common examples of this are resizing and rotating. For this reason, it is better to retransform the original surface than to keep transforming an image multiple times. (For example, suppose you are animating a bouncing spring which expands and contracts. If you applied the size changes incrementally to the previous images, you would lose detail. Instead, always begin with the original image and scale to the desired <tt>size.)</tt> </p>
<!--COMMENTS:pygame.transform--> &nbsp;<br> 


<a name="pygame.transform.flip">
<big><b>pygame.transform.flip</big></b><br><ul>
  <i>flip vertically and horizontally</i><br>
  <tt>pygame.transform.flip(Surface, xbool, ybool): return Surface</tt><br>
<p>This can flip a Surface either vertically, horizontally, or both. Flipping a Surface is nondestructive and returns a new Surface with the same dimensions. </p>
<!--COMMENTS:pygame.transform.flip--> &nbsp;<br> 
<br></ul>


<a name="pygame.transform.scale">
<big><b>pygame.transform.scale</big></b><br><ul>
  <i>resize to new resolution</i><br>
  <tt>pygame.transform.scale(Surface, (width, height), DestSurface = None): return Surface</tt><br>
<p>Resizes the Surface to a new resolution. This is a fast scale operation that does not sample the results. </p>
<p>An optional destination surface can be used, rather than have it create a new one. This is quicker if you want to repeatedly scale something. However the destination must be the same size as the (width, height) passed in. Also the destination surface must be the same format. </p>
<!--COMMENTS:pygame.transform.scale--> &nbsp;<br> 
<br></ul>


<a name="pygame.transform.rotate">
<big><b>pygame.transform.rotate</big></b><br><ul>
  <i>rotate an image</i><br>
  <tt>pygame.transform.rotate(Surface, angle): return Surface</tt><br>
<p>Unfiltered counterclockwise rotation. The angle argument represents degrees and can be any floating point value. Negative angle amounts will rotate clockwise. </p>
<p>Unless rotating by 90 degree increments, the image will be padded larger to hold the new size. If the image has pixel alphas, the padded area will be transparent. Otherwise pygame will pick a color that matches the Surface colorkey or the topleft pixel value. </p>
<!--COMMENTS:pygame.transform.rotate--> &nbsp;<br> 
<br></ul>


<a name="pygame.transform.rotozoom">
<big><b>pygame.transform.rotozoom</big></b><br><ul>
  <i>filtered scale and rotation</i><br>
  <tt>pygame.transform.rotozoom(Surface, angle, scale): return Surface</tt><br>
<p>This is a combined scale and rotation transform. The resulting Surface will be a filtered 32-bit Surface. The scale argument is a floating point value that will be multiplied by the current resolution. The angle argument is a floating point value that represents the counterclockwise degrees to rotate. <tt>A</tt> negative rotation angle will rotate clockwise. </p>
<!--COMMENTS:pygame.transform.rotozoom--> &nbsp;<br> 
<br></ul>


<a name="pygame.transform.scale2x">
<big><b>pygame.transform.scale2x</big></b><br><ul>
  <i>specialized image doubler</i><br>
  <tt>pygame.transform.scale2x(Surface, DestSurface = None): Surface</tt><br>
<p>This will return a new image that is double the size of the original. It uses the AdvanceMAME Scale2X algorithm which does a 'jaggie-less' scale of bitmap graphics. </p>
<p>This really only has an effect on simple images with solid colors. On photographic and antialiased images it will look like a regular unfiltered scale. </p>
<p>An optional destination surface can be used, rather than have it create a new one. This is quicker if you want to repeatedly scale something. However the destination must be twice the size of the source surface passed in. Also the destination surface must be the same format. </p>
<!--COMMENTS:pygame.transform.scale2x--> &nbsp;<br> 
<br></ul>


<a name="pygame.transform.chop">
<big><b>pygame.transform.chop</big></b><br><ul>
  <i>remove interior area of an image</i><br>
  <tt>pygame.transform.chop(Surface, rect): return Surface</tt><br>
<p>Extracts a portion of an image. All vertical and horizontal pixels surrounding the given rectangle area are removed. The resulting image is shrunken by the size of pixels removed. (The original image is not altered by this <tt>operation.)</tt> </p>
<!--COMMENTS:pygame.transform.chop--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>
